<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考研调剂推荐</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        label, input, select, button { display: block; margin-top: 10px; }
        input, select, button { width: 300px; padding: 10px; }
        button { cursor: pointer; }
    </style>
</head>
<body>
<h1>考研调剂推荐系统</h1>
<form id="recommendationForm">
    <label for="major">专业:</label>
    <input type="text" id="major" name="major" required>

    <label for="score">分数:</label>
    <input type="number" id="score" name="score" required>

    <label for="mathType">数学类型:</label>
    <select id="mathType" name="mathType">
        <option value="数学一">数学一</option>
        <option value="数学二">数学二</option>
    </select>

    <label for="englishType">英语类型:</label>
    <select id="englishType" name="englishType">
        <option value="英语一">英语一</option>
        <option value="英语二">英语二</option>
    </select>

    <button type="button" onclick="submitRecommendationRequest()">提交</button>
</form>

<h2>可以考虑:</h2>
<div id="results"></div>

<script>
    function submitRecommendationRequest() {
        var major = document.getElementById('major').value;
        var score = document.getElementById('score').value;
        var mathType = document.getElementById('mathType').value;
        var englishType = document.getElementById('englishType').value;

        fetch(`http://localhost:8087/exam/evaluate?major=${encodeURIComponent(major)}&score=${score}&mathType=${encodeURIComponent(mathType)}&englishType=${encodeURIComponent(englishType)}`)
            .then(response => response.text())
            .then(data => {
                document.getElementById('results').innerText = data;
            })
            .catch(error => {
                console.error('Error fetching data:', error);
                document.getElementById('results').innerText = 'Error fetching results.';
            });
    }
</script>
</body>
</html>
